<?php
/************************************************************************
Class Pick_Core_Pick
----------------------------------------------------------------
PICKCOCMS Project
Company: PICKCO  Co., Ltd 
Name: Nguyen Hai Nam                                  
Last updated: 29/10/2012
**************************************************************************/
class Pick_Core_Pick{
	
	// smarty's object
	public $template = array(); 
	// script array
	public $scripts = array(); 
	// css array...
	public $css = array();
	// array language
	public $messages = array();
	// theme...
	public $theme = "default";
	// layout...
	public $layout = "index";
	// url...
	public $url;
	// op...
	public $op;
	// lang...
	public $lang;
		
	function Pick_Core_Pick() {
		
		global $template, $messages, $request, $url, $op, $lang;
		$this->template = $template;
		$this->messages = $messages;
		$this->request	= $request;
		$this->url = $url;
		$this->op = $op;
		$this->lang = $lang;
	}
	
	// get variable of smarty
	public function getVariableForSmarty(){
		$this->template->assign("base_url", base_url());
		$this->template->assign("current_url", current_url());
		$this->template->assign("lang", $this->lang);		
		$this->template->assign("url", $this->url);
		$this->template->assign("op", $this->op);
		$this->template->assign("usertemplate", $this->theme);
		$this->template->assign("scripts", $this->scripts);
		$this->template->assign("css", $this->css);
		$this->template->assign("this", $this);
	}
	
	// Push a link js or array link js to js properties
	public function pushJS($namefile){
		$this->scripts[] = $namefile;
	}
	
	// Push a link css or array link css to css properties
	public function pushCSS($namefile){
		$this->css[] = $namefile;	
	}
	
	// Get content from template
	public function displayPart($fileTemplate){
		$pathTemplate = ROOT_PATH."templates/".$this->theme."/".$fileTemplate.".temp.html";
		if(file_exists($pathTemplate)){
			return $this->template->fetch($pathTemplate);	
		}else{
			die("The $fileTemplate file isn't exists in your current layout.<br /> Please check at this path: .$pathTemplate");	
		}
	}
	// Get content from template
	public function display(){
		$pathTemplate = ROOT_PATH."templates/".$this->theme."/layout/".$this->layout.".temp.html";
		if(file_exists($pathTemplate)){
			$this->template->display($pathTemplate);	
		}else{
			die("The $fileTemplate file isn't exists in your current layout.<br /> Please check at this path: .$pathTemplate");	
		}
	}
	// Get language for module
	public function l($key){
		return l($key);
	}
}
?>